#include "..\..\StdAfx.h"
#include "EnterMineAndDigForNugget.h"
#include "VisitBankAndDepositGold.h"
#include "QuenchThirst.h"


EnterMineAndDigForNugget::~EnterMineAndDigForNugget(void)
{
}


bool EnterMineAndDigForNugget::Enter(Miner* pEntity, float fTime)
{
	_TRACE(_T("Enter EnterMineAndDigForNugget.\n"));

	if (pEntity->Location() != GoldMine)
		pEntity->SetDestination(GoldMine);

	m_fStateEnterTime = fTime;
	return true;
}

bool EnterMineAndDigForNugget::Execute(Miner* pEntity, float fTime)
{
	if (pEntity->Location() != GoldMine)
		return pEntity->Walking(fTime);

	pEntity->AddToGoldCarried(fTime);
	
	pEntity->IncreaseFatigue();

	if (pEntity->PocketsFull())
		return pEntity->GetFSM()->ChangeState(VisitBankAndDepositGold::Instance(), fTime);

	if (pEntity->Thirsty())
		return pEntity->GetFSM()->ChangeState(QuenchThirst::Instance(), fTime);
	
	return true;
}

bool EnterMineAndDigForNugget::Exit(Miner* pEntity, float fTime)
{
	//std::cout << GetNameOfEntity(pEntity->ID()) << _T(": ") << std::endl;
	return true;
}